package com.woniu.aimd.config.ai.chatclient;

//
import com.woniu.aimd.config.ai.tools.WeathetTool;
import org.springframework.ai.chat.client.ChatClient;
import org.springframework.ai.chat.client.advisor.MessageChatMemoryAdvisor;
import org.springframework.ai.chat.client.advisor.SimpleLoggerAdvisor;
import org.springframework.ai.chat.memory.ChatMemory;
import org.springframework.ai.chat.memory.MessageWindowChatMemory;
import org.springframework.ai.openai.OpenAiChatModel;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

//@Configuration
public class yc_ChatClientConfig {
    @Bean
    public ChatClient deepSeekChatClient(OpenAiChatModel deepSeekModel,
                                         @Qualifier("javaChatMemory") ChatMemory chatMemory,
                                         WeathetTool weathetTool) {

        return ChatClient.builder(deepSeekModel)
                .defaultSystem("""
                        从用户输入的信息里面，提取省份：province，成实：city，和
                        时间：date，如果没有省份信息，需要你来自行判断这个city属于哪个省份
                        """).defaultTools(weathetTool)
                .defaultAdvisors(MessageChatMemoryAdvisor.builder(chatMemory).build())
                //, MessageChatMemoryAdvisor.builder(chatMemory).build() 会话记忆
                .defaultAdvisors(new SimpleLoggerAdvisor())
                .build();
    }

    @Bean
    ChatMemory javaChatMemory() {
        return MessageWindowChatMemory.builder().build();
    }
}
